package com.example.mygame.utils;

import android.R.integer;
import android.app.Activity;
import android.content.Context;

public class Utils {
	private static Utils instance = null;
	static Context mContext = null;
	public static Utils getInstance(Context activity) {
		
		if (instance == null) {
			mContext = activity;
			instance = new Utils();
		}
		
		return instance;
	}

	
	public int dp2px(int dp) {
		return (int)mContext.getResources().getDisplayMetrics().density * dp;
	}
	
	public int viewWidth() {
		int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
		int heightPixels = mContext.getResources().getDisplayMetrics().heightPixels;
		return widthPixels>heightPixels ? heightPixels : widthPixels;
	}
	
	public int screenHeight() {
		return mContext.getResources().getDisplayMetrics().heightPixels;
	}
	
	public int screenWidth() {
		return mContext.getResources().getDisplayMetrics().widthPixels;
	}
}
